#pragma once

#include <boost\asio.hpp>
#include <boost\noncopyable.hpp>	
#include <boost\shared_ptr.hpp>
#include <boost\enable_shared_from_this.hpp>

namespace jump
{
	namespace client{
	
		class Connection_Manage;

		class Connection
			:private boost::noncopyable,
			public boost::enable_shared_from_this<Connection>
			
		{
		public:
			explicit Connection(boost::asio::io_service& arg_ioService,Connection_Manage& arg_conn_mgr);

			boost::asio::ip::tcp::socket& socket();

			void start();

			void stop();

		private:

			void handle_write(const boost::system::error_code& arg_err);
			void handle_read(const boost::system::error_code& arg_err);


			boost::asio::ip::tcp::socket socket_;
		

			Connection_Manage& connectionMgr_;
			//buffer area
			//boost::asio::streambuf sendBuf_;
			//boost::asio::streambuf recvBuf_;

			enum
			{
				MAX_LENGTH = 16
			};
			char buf_[MAX_LENGTH];
			
		};
		
		typedef boost::shared_ptr<Connection> connection_ptr;

	}//namespace client
}//namespace jump
//#ifndef HTTP_CLIENT_CONNECTION_H
//#define HTTP_CLIENT_CONNECTION_H
//
//#endif